﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;

using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;

using System.IO;

namespace NotebookS2
{
    public partial class PrintPreviewCVW : RibbonForm
    {
        
      
        public string DocumentNumber { get; set; }
        public string ConnectionString { get; set; }
        public string ReportFileName { get; set; }

        public PrintPreviewCVW()
        {
           
            InitializeComponent();
        }

        #region Marketing Documents Print Preview

        public void ViewPurchasesLayout( string sDocNumber)
        {
            ReportDocument rptDoc = new ReportDocument();
            SqlConnection oConnection = new SqlConnection();
            SqlCommand oCommand = new SqlCommand();
            SqlDataAdapter oAdapter = new SqlDataAdapter();
            DataSet ds = new DataSet();

            string sReportFile = @"D:\Documents\VS2012\NotebookS2\NotebookS2\Layout\PO.rpt";

            rptDoc.Load(sReportFile);


           this.DocumentNumber = sDocNumber;

            oConnection.ConnectionString = this.ConnectionString;
            oConnection.Open();

            oCommand.Connection = oConnection;
            oCommand.CommandType = CommandType.StoredProcedure;
            oCommand.CommandText = "SP_DOCUMENT";

            oCommand.Parameters.Add(new SqlParameter("@DOCNUM", sDocNumber));
            oAdapter.SelectCommand = oCommand;
            oAdapter.Fill(ds);

            oConnection.Close();

            rptDoc.SetDataSource(ds.Tables[0]);
            CRViewer.ReportSource = rptDoc;
            CRViewer.Refresh();
        }

        public void ViewLayout(string sDocNumber)
        {
            //Layout.PO oPp = new Layout.PO();
            //oPp.Parameter_DOCNUM.CurrentValues.Add(sDocNumber);
            
            


        }
        #endregion


        private void PrintPreviewCVW_Load(object sender, EventArgs e)
        {
            ViewPurchasesLayout(this.DocumentNumber);
        }

    }
}
